<?php
@session_start();
$PurviewLevel=2;
$CheckChannelID=0;  
$PurviewLevel_Others="tongjing_user";

require("../../inc/common.inc.php");
require_once("../Admin_ChkPurview.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>铭讯EOS网站后台管理</TITLE>
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<link rel="stylesheet" href="../images/style.css" type="text/css">
</head>
<body>
<?php
require("../mx_head.php");
?>
<div class="right">
<div class="gk">
	<div class="ti2 fl">用户统计</div>
	<ul class="fr">
		<?php
		$lastinfo=$db->getinfo("select * from mx_tj_user order by tjdate desc limit 1");
		?>
		<li><span class="c1"><?php echo (float)$lastinfo["tjzong"]?></span><span>用户总数</span></li>
		<li class="line"></li>
		<li><span class="c2"><?php echo (float)$lastinfo["vpp_zong"]?></span><span>VPP用户</span></li>
		<li class="line"></li>
		<li><span class="c3"><?php echo (float)$lastinfo["app_zong"]?></span><span>APP用户</span></li>
		<li class="line"></li>
		<li><span class="c4"><?php echo $lastinfo["vpp_add"]+$lastinfo["app_add"]?></span><span>今日新增</span></li>
	</ul>
	<div class="clear"></div>
	</div>
	<div class="clear"></div>
	<div class="height15"></div>
	<div class="clear"></div>
	<div class="xm2">
		<h1 class="fl">用户增长（VPP+APP用户）</h1>
		<div class="clear"></div>
	</div>
	<div class="xm2_b">
				<div class="height15"></div>
				<div class="zengzhang">
				<?php
				$today=date("Y-m-d");
				$today=date("Y-m-d",strtotime(" $today-1 day"));
				$predate=date("Y-m-d",strtotime(" $today-1 day"));
				$thisweekday=aweek($today);
				$preweekday=aweek(date("Y-m-d",strtotime(" $today-7 day")));
				$thismonth=getthemonth($today);
				$premonth=getthemonth(date("Y-m-d",strtotime(date("Y-m")."-1 - 1 month")));
				//上一天数据
				$preinfo=$db->getinfo("select * from mx_tj_user where tjdate='".$predate."'");
				
				//周
				$thisweekdayinfo=$db->getinfo("select sum(vpp_add) as vpp_add,sum(vpp_cancel) as vpp_cancel,sum(vpp_jingadd) as vpp_jingadd,sum(vpp_zong) as vpp_zong,sum(app_add) as app_add,sum(app_cancel) as app_cancel,sum(app_jingadd) as app_jingadd,sum(app_zong) as app_zong,sum(tjzong) as tjzong from mx_tj_user where tjdate>='$thisweekday[0]' and tjdate<='$thisweekday[1]'");
				//$thisweekdayinfo_z=$db->getinfo("select * from ");
				
				$preweekdayinfo=$db->getinfo("select sum(vpp_add) as vpp_add,sum(vpp_cancel) as vpp_cancel,sum(vpp_jingadd) as vpp_jingadd,sum(vpp_zong) as vpp_zong,sum(app_add) as app_add,sum(app_cancel) as app_cancel,sum(app_jingadd) as app_jingadd,sum(app_zong) as app_zong,sum(tjzong) as tjzong from mx_tj_user where tjdate>='$preweekday[0]' and tjdate<='$preweekday[1]'");
				
				//月
				$thismonthinfo=$db->getinfo("select sum(vpp_add) as vpp_add,sum(vpp_cancel) as vpp_cancel,sum(vpp_jingadd) as vpp_jingadd,sum(vpp_zong) as vpp_zong,sum(app_add) as app_add,sum(app_cancel) as app_cancel,sum(app_jingadd) as app_jingadd,sum(app_zong) as app_zong,sum(tjzong) as tjzong from mx_tj_user where tjdate>='$thismonth[0]' and tjdate<='$thismonth[1]'");

				$premonthinfo=$db->getinfo("select sum(vpp_add) as vpp_add,sum(vpp_cancel) as vpp_cancel,sum(vpp_jingadd) as vpp_jingadd,sum(vpp_zong) as vpp_zong,sum(app_add) as app_add,sum(app_cancel) as app_cancel,sum(app_jingadd) as app_jingadd,sum(app_zong) as app_zong,sum(tjzong) as tjzong from mx_tj_user where tjdate>='$premonth[0]' and tjdate<='$premonth[1]'");
				?>
				<table width="90%" height="123" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="22%" class="bor_r"><div class="w115"><div class="span1">新关注人数</div><div class="span2"><?php echo $lastinfo["vpp_add"]+$lastinfo["app_add"];?></div>
					<?php
					$arr=get_baifenbi($lastinfo["app_add"]+$lastinfo["vpp_add"],$preinfo["app_add"]+$preinfo["vpp_add"]);
					$arr_c=get_baifenbi($lastinfo["vpp_cancel"]+$lastinfo["app_cancel"],$preinfo["vpp_cancel"]+$preinfo["app_cancel"]);
					$arr_j=get_baifenbi($lastinfo["vpp_jingadd"]+$lastinfo["app_jingadd"],$preinfo["vpp_jingadd"]+$preinfo["app_jingadd"]);
					$arr_z=get_baifenbi($lastinfo["tjzong"],$preinfo["tjzong"]);
					
					$w_arr=get_baifenbi($thisweekdayinfo["app_add"]+$thisweekdayinfo["vpp_add"],$preweekdayinfo["app_add"]+$preweekdayinfo["vpp_add"]);
					$w_arr_c=get_baifenbi($thisweekdayinfo["vpp_cancel"]+$thisweekdayinfo["app_cancel"],$preweekdayinfo["vpp_cancel"]+$preweekdayinfo["app_cancel"]);
					$w_arr_j=get_baifenbi($thisweekdayinfo["vpp_jingadd"]+$thisweekdayinfo["app_jingadd"],$preweekdayinfo["vpp_jingadd"]+$preweekdayinfo["app_jingadd"]);


					$m_arr=get_baifenbi($thismonthinfo["app_add"]+$thismonthinfo["vpp_add"],$premonthinfo["app_add"]+$premonthinfo["vpp_add"]);
					$m_arr_c=get_baifenbi($thismonthinfo["vpp_cancel"]+$thismonthinfo["app_cancel"],$premonthinfo["vpp_cancel"]+$premonthinfo["app_cancel"]);
					$m_arr_j=get_baifenbi($thismonthinfo["vpp_jingadd"]+$thismonthinfo["app_jingadd"],$premonthinfo["vpp_jingadd"]+$premonthinfo["app_jingadd"]);
					?>
					<span class="span3">日：<span class="<?php echo $arr[0];?>"><?php echo $arr[1];?></span></span>
					<span class="span3">周：<span class="<?php echo $w_arr[0];?>"><?php echo $w_arr[1];?></span></span>
					<span class="span3">月：<span class="<?php echo $m_arr[0];?>"><?php echo $m_arr[1];?></span></span>
					</div></td>
                    <td width="26%" class="bor_r"><div class="w115"><div class="span1">取消关注人数</div><div class="span2"><?php echo $lastinfo["vpp_cancel"]+$lastinfo["app_cancel"];?></div>
                    <span class="span3">日：<span class="<?php echo $arr_c[0];?>"><?php echo $arr_c[1];?></span></span>
					<span class="span3">周：<span class="<?php echo $w_arr_c[0];?>"><?php echo $w_arr_c[1];?></span></span>
					<span class="span3">月：<span class="<?php echo $m_arr_c[0];?>"><?php echo $m_arr_c[1];?></span></span>
					</div></td>
                    <td width="26%" class="bor_r"><div class="w115"><div class="span1">净增关注人数</div><div class="span2"><?php echo $lastinfo["vpp_jingadd"]+$lastinfo["app_jingadd"];?></div>
					<span class="span3">日：<span class="<?php echo $arr_j[0];?>"><?php echo $arr_j[1];?></span></span>
					<span class="span3">周：<span class="<?php echo $w_arr_j[0];?>"><?php echo $w_arr_j[1];?></span></span>
					<span class="span3">月：<span class="<?php echo $m_arr_j[0];?>"><?php echo $m_arr_j[1];?></span></span>
					</div></td>
                    <td width="26%"><div class="w115"><div class="span1">累计关注人数</div>
                    <div class="span2"><?php echo $lastinfo["tjzong"]?></div>
                    <span class="span3">日：<span class="<?php echo $arr_z[0];?>"><?php echo $arr_z[1];?></span></span>
					<span class="span3">周：--</span>
					<span class="span3">月：--</span>
					</div></td>
                  </tr>
                </table>
				</div>
				<div class="height15"></div>
	</div>
	
		<div class="clear"></div>
		<div class="height15"></div>
		<div class="xm2">
			<h1 class="fl">概况</h1>
			<div class="clear"></div>
		</div>
		<div class="xm2_b">
		<div class="height15"></div>
		<?php
		$startdate=formatdate($startdate);
		$enddate=formatdate($enddate);
		if ($startdate=="" or $enddate==""){
			$enddate=date("Y-m-d");
			$startdate=date("Y-m-d",strtotime("$enddate - 30 day"));
		}
		?>
		    <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">
              <tr>
                <td width="190" align="center">
<script>
	var jQuery_1 = $.noConflict(true);
    var minValidDate = 1372608000;
</script>	
<link rel="stylesheet" type="text/css" href="../js/date.css" charset="utf-8">
<script type="text/javascript" src="../js/gri.dateRange.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/gri.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/mta.js" charset="utf-8"></script>
<!--==时间范围start==-->
<form name="form1" id="form1" action="tj_user.php" method="get">
<input type="text" name="selectdate" id="selectdate" class="input1" style="width:180px;">
<input type="hidden" name="startdate" value="<?php echo $startdate;?>">
<input type="hidden" name="enddate" value="<?php echo $enddate;?>">
<input type="hidden" name="actions" value="<?php echo $actions;?>" />
</form>
<!--==时间范围end==-->
 
<script type="text/javascript"> 
    //应用的初始化参数
    var initParams = {
	"start_date": "<?php echo $startdate;?>",
	"end_date": "<?php echo $enddate;?>",	
	"need_compare": 1,
	};
 
    jQuery_1(document).ready(function(){
 
        var dateObj = {
            inputId:'selectdate',
            target:'datePicker',
            startDate: initParams.start_date || '',
            endDate: initParams.end_date || '',
            startCompareDate: initParams.start_compare_date || '',
            endCompareDate: initParams.end_compare_date || '',
            needCompare: initParams.need_compare || '1',
            defaultText : ''|| ' 至 ',
            singleCompare : '',
            isTodayValid: 0,
            minValidDate: minValidDate
        };
 
        //MTA.Page.Condition.source = new MTA.Selector('#div_source', 'source', initParams.source, 'buildData');
 
        MTA.Report.initialize(dateObj, 'buildData');
 
        //页面tips
    });
	function selectdate_submit(){
		var selectdatestr=document.form1.selectdate.value;
		if (selectdatestr!=""){
			selectdatearr=selectdatestr.split(' 至 ');
			if (selectdatearr.length==2){
				document.form1.startdate.value=selectdatearr[0];
				document.form1.enddate.value=selectdatearr[1];
				document.form1.submit();
			}
		}
	}
</script>
				</td>
                <td>
				<div class="an<?php if (trim($actions)==""){echo "1";}else{echo "2";}?>"><a href="tj_user.php?startdate=<?php echo $startdate;?>&enddate=<?php echo $enddate;?>">新增人数</a></div>
				<div class="an<?php if (trim($actions)=="quxiao"){echo "1";}else{echo "2";}?>"><a href="tj_user.php?actions=quxiao&startdate=<?php echo $startdate;?>&enddate=<?php echo $enddate;?>">取消关注人数</a></div>
				<div class="an<?php if (trim($actions)=="jingzeng"){echo "1";}else{echo "2";}?>"><a href="tj_user.php?actions=jingzeng&startdate=<?php echo $startdate;?>&enddate=<?php echo $enddate;?>">净增人数</a></div>
				<div class="an<?php if (trim($actions)=="leiji"){echo "1";}else{echo "2";}?>"><a href="tj_user.php?actions=leiji&startdate=<?php echo $startdate;?>&enddate=<?php echo $enddate;?>">累计人数</a></div></td>
              </tr>
            </table>
			<div class="height15"></div>
				<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td>
<?php
$str="";
if ($startdate!=""){
	$str.=" and tjdate>='$startdate' ";
}
if ($enddate!=""){
	$str.=" and tjdate<='$enddate' ";
}
$rs=$db->excu("select * from mx_tj_user where id>0 $str order by tjdate asc,id asc");
if ($db->num_rows($rs)>0){
	while ($rsdb=$db->fetch_array($rs)){
		$thisdate[]=$rsdb;
	}
}
?>
<script src="../js/jquery.min.js"></script>
<script src="../js/highcharts/tongji.js"></script>
<script src="../js/highcharts/highcharts.js"></script>
<script src="../js/handsontable/jquery.handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="../js/handsontable/jquery.handsontable.full.css">
<div id="data_div"></div>
<div id="charts" style="width: 99%; margin: 0; padding: 0;"></div>
<script type="text/javascript"> 
<!--
<?php
if (is_array($thisdate)){
$thisdatenum=count($thisdate);
if ($thisdatenum<10){
	$ge=1;
}
else if ($thisdatenum<=20){
	$ge=2;
}
else if ($thisdatenum<=40){
	$ge=3;
}
else if ($thisdatenum<=50){
	$ge=5;
}
else{
	$ge=10;
}
if (trim($actions)=="quxiao"){
?>
var data = [
	["", "人数"],
	<?php
	$i=0;
	foreach ($thisdate as $key =>$value){
		if (($i%$ge==0) or ($i%$ge!=0 and $i==$thisdatenum-1)){
			echo '["'.date("m/d",strtotime($value["tjdate"])).'",'.($value["vpp_cancel"]+$value["app_cancel"]).'],';
		}
		else{
			echo '[" ",'.($value["vpp_cancel"]+$value["app_cancel"]).'],';
		}
		$i++;
	}
	?>
];
<?php }
elseif (trim($actions)=="jingzeng"){
?>
var data = [
	["", "人数"],
	<?php
	$i=0;
	foreach ($thisdate as $key =>$value){
		if (($i%$ge==0) or ($i%$ge!=0 and $i==$thisdatenum-1)){
			echo '["'.date("m/d",strtotime($value["tjdate"])).'",'.($value["vpp_jingadd"]+$value["app_jingadd"]).'],';
		}
		else{
			echo '[" ",'.($value["vpp_jingadd"]+$value["app_jingadd"]).'],';
		}
		$i++;
	}
	?>
];
<?php }
elseif (trim($actions)=="leiji"){
?>
var data = [
	["", "人数"],
	<?php
	$i=0;
	foreach ($thisdate as $key =>$value){
		if (($i%$ge==0) or ($i%$ge!=0 and $i==$thisdatenum-1)){
			echo '["'.date("m/d",strtotime($value["tjdate"])).'",'.$value["tjzong"].'],';
		}
		else{
			echo '[" ",'.$value["tjzong"].'],';
		}
		$i++;
	}
	?>
];
<?php }
else{
?>
var data = [
	["", "人数"],
	<?php
	$i=0;
	foreach ($thisdate as $key =>$value){
		if (($i%$ge==0) or ($i%$ge!=0 and $i==$thisdatenum-1)){
			echo '["'.date("m/d",strtotime($value["tjdate"])).'",'.($value["vpp_add"]+$value["app_add"]).'],';
		}
		else{
			echo '[" ",'.($value["vpp_add"]+$value["app_add"]).'],';
		}
		$i++;
	}
	?>
];
<?php
}
}?>
 

$(function(){
	$(document).ready(function() {
		var table = $('#data_div').handsontable({
			minRows: 1,
			minCols: 5,
			minSpareRows: 1,
			minSpareCols: 1,
			rowHeaders: true,
			colHeaders: true,
			data: data
		}).data('handsontable');
			var datagrid = table.getData();
			var type = "line";
			var title = "";
			var ytitle = "";
			show_chart(type, title, ytitle,datagrid);
			return false;
	});
});
 
//-->
</script>
					</td>
                  </tr>
                </table>
				<div class="height15"></div>
	  </div>
		<div class="clear"></div>
		<div class="height15"></div>
        <div class="xm2">
          <h1 class="fl">详细数据</h1>
          <div class="clear"></div>
        </div>
		<div class="xm2_b">
		  <div class="height15"></div>
	
	<script type="text/javascript" src="../js/jquery.tablesorter.js"></script>
	<script type="text/javascript" src="../js/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" id="js">$(document).ready(function() {
	$("table").tablesorter();
}); </script>
          <table width="98%" border="0" align="center" cellpadding="9" cellspacing="1" bgcolor="#CCCCCC" class="table_southidc" id="table">
		  <thead>
            <tr align="center">
              <th width="16%"><span>时间</span></th>
              <th width="21%"><span>新关注人数</span></th>
              <th width="21%"><span>取消关注人数</span></th>
              <th width="21%"><span>净增关注人数</span></th>
              <th width="21%"><span>累计关注人数</span></th>
            </tr>
			</thead>
			<tbody>
			<?php
			if (is_array($thisdate)){
			foreach ($thisdate as $key =>$value){
			?>
            <tr align="center" class="list" >
              <td><?php echo $value["tjdate"];?></td>
              <td><?php echo $value["vpp_add"]+$value["app_add"];?></td>
              <td><?php echo $value["vpp_cancel"]+$value["app_cancel"];?></td>
              <td><?php echo $value["vpp_jingadd"]+$value["app_jingadd"];?></td>
              <td><?php echo $value["tjzong"];?></td>
            </tr>
			<?php
			}
			}
			else{
			?>
			<tr class="list"><td align="center" colspan="5">暂无信息</td></tr>
			<?php
			}
			?>
			</tbody>
          </table>
		  
		  <div class="height15"></div>
	  </div>
		<div class="clear"></div>
  </div>
	
</div>
</div>
<?php require("../mx_foot.php");?>
</body>
</html>
